Skip to content

ref(analytics): Transform analytics events for TET-828 #95208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

constantinius
Copy link
Contributor

  • Transform event classes to use @analytics.eventclass decorator
  • Transform analytics.record calls to use event class instances
  • Update imports as needed

Closes TET-828

- Transform event classes to use @analytics.eventclass decorator
- Transform analytics.record calls to use event class instances
- Update imports as needed

Closes TET-828
@constantinius constantinius requested review from a team as code owners July 10, 2025 09:13
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 10, 2025
cursor[bot]

This comment was marked as outdated.

Copy link

codecov bot commented Jul 10, 2025

❌ 44 Tests Failed:

Tests completed Failed Passed Skipped
27218 44 27174 243
View the top 3 failed test(s) by shortest run time
tests.sentry.analytics.test_base.AnalyticsTest::test_record
Stack Traces | 0.735s run time
#x1B[1m#x1B[.../sentry/analytics/test_base.py#x1B[0m:23: in test_record
    assert event.data["slug"] == organization.slug
#x1B[1m#x1B[31mE   TypeError: 'NoneType' object is not subscriptable#x1B[0m
tests.sentry.api.endpoints.test_organization_index.OrganizationsCreateTest::test_org_ownership
Stack Traces | 2.09s run time
#x1B[1m#x1B[.../api/endpoints/test_organization_index.py#x1B[0m:153: in test_org_ownership
    response = self.get_success_response(**data)
#x1B[1m#x1B[.../sentry/testutils/cases.py#x1B[0m:626: in get_success_response
    assert_status_code(response, 200, 300)
#x1B[1m#x1B[.../sentry/testutils/asserts.py#x1B[0m:45: in assert_status_code
    assert minimum <= response.status_code < maximum, (
#x1B[1m#x1B[31mE   AssertionError: (500, b'{"detail":"Internal Error","errorId":null}')#x1B[0m
#x1B[1m#x1B[31mE   assert 500 < 300#x1B[0m
#x1B[1m#x1B[31mE    +  where 500 = <Response status_code=500, "application/json">.status_code#x1B[0m
tests.sentry.api.endpoints.test_organization_index.OrganizationsCreateTest::test_with_default_team_false
Stack Traces | 2.1s run time
#x1B[1m#x1B[.../api/endpoints/test_organization_index.py#x1B[0m:163: in test_with_default_team_false
    response = self.get_success_response(**data)
#x1B[1m#x1B[.../sentry/testutils/cases.py#x1B[0m:626: in get_success_response
    assert_status_code(response, 200, 300)
#x1B[1m#x1B[.../sentry/testutils/asserts.py#x1B[0m:45: in assert_status_code
    assert minimum <= response.status_code < maximum, (
#x1B[1m#x1B[31mE   AssertionError: (500, b'{"detail":"Internal Error","errorId":null}')#x1B[0m
#x1B[1m#x1B[31mE   assert 500 < 300#x1B[0m
#x1B[1m#x1B[31mE    +  where 500 = <Response status_code=500, "application/json">.status_code#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing Fields in Organization Event

The OrganizationCreatedEvent instance is missing required id, name, and slug fields. Previously, the org object was passed to analytics.record, which provided these values. The new event instance only passes actor_id, omitting these required fields that should be extracted from the org object, leading to incomplete or failed analytics events.

src/sentry/api/endpoints/organization_index.py#L281-L286

analytics.record(
OrganizationCreatedEvent(
actor_id=request.user.id if request.user.is_authenticated else None,
)
)

Fix in CursorFix in Web


Bug: Event Constructor Mismatch Causes Error

The AlertCreatedEvent constructor is incorrectly passed project_id, referrer, and session_id parameters. These fields are not defined in the AlertCreatedEvent class, leading to a TypeError when the event is instantiated.

src/sentry/receivers/features.py#L358-L374

analytics.record(
AlertCreatedEvent(
user_id=user_id,
default_user_id=default_user_id,
organization_id=project.organization_id,
project_id=project.id,
rule_id=rule_id,
rule_type=rule_type,
referrer=referrer,
session_id=session_id,
is_api_token=is_api_token,
alert_rule_ui_component=alert_rule_ui_component,
duplicate_rule=duplicate_rule,
wizard_v3=wizard_v3,
query_type=query_type,
)
)

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant